package com.hopu.blb_erp.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hopu.blb_erp.entity.Order;
import com.hopu.blb_erp.entity.PageEntity;
import com.hopu.blb_erp.entity.TShipping;
import com.hopu.blb_erp.mapper.OrderMapper;
import com.hopu.blb_erp.mapper.ShippingMapper;
import com.hopu.blb_erp.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService {
    @Autowired
    private OrderMapper orderMapper;

    @Override
    public Integer findCount() {
        return orderMapper.selectCount();
    }

    @Override
    public PageEntity<Order> findPage(Integer current, Integer pageSize) {
        Integer count = orderMapper.selectCount();
        List<Order> orders = orderMapper.selectPage((current - 1) * pageSize, pageSize);
        PageEntity<Order> orderPageEntity = new PageEntity<>();
        orderPageEntity.setData(orders);
        orderPageEntity.setCurrent(current);
        orderPageEntity.setCount(count);
        return orderPageEntity;
    }

    @Override
    public Order findOrderByOrderId(String orderId) {
        Order order = orderMapper.selectOrderByOrderId(orderId);
        return order;
    }
}
